{% extends "../component/_latout.html" %}
{% block style %}
<link href="/public/admin/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
{% endblock %}
{% block content %}
<!--wrap-->
<div>
    <!--主体部分-->
    <div class="row">
        <div class="col-sm-12">
          <div class="ibox m-b-none float-e-margins">
              <div class="ibox-title">
                  <h5>文章-所有文章</h5>
                  <div class="ibox-tools">
                      
                  </div>
              </div>
              <div class="ibox-content">
                <div class="clear">
                  <div class="btn-group pull-left">
                      <a class="btn btn-outline btn-primary {% if params.publish %}{%else%}active{% endif %}" {% if params.publish %}href="/admin/article/list"{% endif %}>全部</a>
                      <a class="btn btn-outline btn-primary {% if params.publish==1 %}active{% endif %}" {% if params.publish != 1 %}href="/admin/article/list?publish=1"{% endif %}>已发布</a>
                      <a class="btn btn-outline btn-primary {% if params.publish==0 %}active{% endif %}" {% if params.publish != 0 %}href="/admin/article/list?publish=0"{% endif %}>未发布</a>
                  </div>
                  <div class="m-l-xl pull-left">
                      <a tabname="写文章" class="btn btn-primary J_menuItem" href="/admin/article/new">发布新文章</a>
                  </div>
                </div>
                <!--共多少篇文章-->
                <div class="ibox m-t-md m-b-none">
                  <form method="get" class="form-horizontal">
                    <div class="clear">
                            <label class="control-label pull-left m-r-sm">
                                <h4 class="tx-l">
                                    筛选:
                                </h4>
                            </label>
                            <div class="clear pull-left">
                                <div class="my-select-control pull-left m-r-sm">
                                    <select class="form-control" name="orderBy">
                                        <option value="modify_time" {% if params.orderBy == "modify_time" %}selected{% endif %}>修改时间排序</option>
                                        <option value="create_time" {% if params.orderBy == "create_time" %}selected{% endif %}>创建时间排序</option>
                                        <option value="publish_time" {% if params.orderBy == "publish_time" %}selected{% endif %}>发布时间排序</option>
                                        <option value="view_count" {% if params.orderBy == "view_count" %}selected{% endif %}>浏览量排序</option>
                                    </select>
                                </div>
                                <div class="my-select-control pull-left m-r-sm">
                                    <select class="form-control" name="order">
                                        <option value="ASC" {% if params.order == "ASC" %}selected{% endif %}>升序</option>
                                        <option value="DESC" {% if params.order == "DESC" %}selected{% endif %}>降序</option>
                                    </select>
                                </div>
                            </div>
                            <label class="control-label pull-left m-l-sm m-r-sm">
                                <h4 class="tx-l">
                                    文章分类:
                                </h4>
                            </label>
                            <div class="clear pull-left">
                                <div class="my-select-control pull-left m-r-sm">
                                    <select class="form-control" name="type">
                                        <option value="">请选择分类</option>
                                        {% for articleType in types %}
                                        <optgroup label="{{ articleType.name }}">
                                        {# <option value="{{ articleType.id }}" articleTypeId="{{ articleType.id }}" {% if params.type == articleType.id %}selected{% endif %}>{{ articleType.name }}</option> #}
                                            {% if articleType.children.length !== 0 %}
                                            {% for subarticleType in articleType.children %}
                                            <option value="{{ subarticleType.id }}" articleTypeId="{{ subarticleType.id }}" {% if params.type == subarticleType.id %}selected{% endif %}>{{ subarticleType.name }}</option>
                                            {% endfor %}
                                            {% endif %}
                                        </optgroup>
                                        {% endfor %}
                                    </select>
                                </div>
                            </div>
                            <div class="input-group-container  pull-right">
                                <div class="input-group">
                                    <input type="text" name="keyword" value="{{ params.keyword }}" placeholder="请输入标题、关键词、作者搜索文章" class="input-sm form-control">
                                    <span class="input-group-btn m-b-none"><button type="button" id="submitSearch" class="btn btn-sm btn-primary">确定</button> </span>
                                </div>
                            </div>
                      </div>
                  </form>
                </div>
              </div>
          </div>
          <!--表格-->
          <div class="my-table ibox-content" >
            <table class="table table-hover  m-b-none" >
              <thead>
                  <tr>
                      {# <th class="bs-checkbox">
                          <div class="th-inner ">
                              <input name="btSelectAll" type="checkbox">
                          </div>
                          <div class="fht-cell"></div>
                      </th> #}
                      <th>
                          <div class="th-inner ">id</div>
                          <div class="fht-cell"></div>
                      </th>
                      <th>
                          <div class="th-inner ">标题</div>
                          <div class="fht-cell"></div>
                      </th>
                      <th>
                          <div class="th-inner ">作者</div>
                          <div class="fht-cell"></div>
                      </th>
                      <th>
                          <div class="th-inner ">分类目录</div>
                          <div class="fht-cell"></div>
                      </th>
                      <th>
                          <div class="th-inner ">日期</div>
                          <div class="fht-cell"></div>
                      </th>
                      <th>
                          <div class="th-inner ">浏览量</div>
                          <div class="fht-cell"></div>
                      </th>
                      <th>
                          <div class="th-inner ">操作</div>
                          <div class="fht-cell"></div>
                      </th>
                  </tr>
              </thead>
              <tbody>
                    {% for article in list %}
                    <tr>
                        {# <td class="bs-checkbox">
                            <input name="btSelectItem" type="checkbox">
                        </td> #}
                        <td>{{ article.id }}</td>
                        <td class="text-success name-ellipse">
                            <a tabname="编辑文章 | {{article.title}}" class="J_menuItem" href="/admin/article/edit?articleId={{article.id}}">{% if article.title %}{{ article.title }}{% else %}未设置{% endif %}</a>
                        </td>
                        <td class="text-success">{% if article.author %}{{ article.author }}{% else %}未设置{% endif %}</td>
                        <td class="text-success">{% if article.articleType.name %}{{ article.articleType.name }}{% else %}未设置{% endif %}</td>
                        <td>最后修改 {{ article.modify_time }}</td>
                        <td>{{ article.view_count }}</td>
                        <td>   
                            <a tabname="编辑文章 | {{article.title}}" class="J_menuItem" href="/admin/article/edit?articleId={{article.id}}">编辑</a>
                            <!--这个地址之后要换成前台地址 -->
                            <input type="text" class="copy_target_input" id="copy_target_{{ article.id }}"  value="/article/detail?articleId={{article.id}}{% if article.articleType.name == '华渔视界' %}&video=1{% endif %}"/>
                            <a href="javascript:void(0)" class="clipUrl" articleId="{{ article.id }}" data-clipboard-action="copy" data-clipboard-target="#copy_target_{{ article.id }}" id="clip_borad_{{ article.id }}" >复制链接</a>
                            <a href="javascript:void(0)" class="delete_article" articleId="{{ article.id }}">删除</a>
                            <a href="javascript:void(0)" class="publish_article" articleId="{{ article.id }}" publish="{{ article.publish }}">{% if article.publish == 0%}发布{% else %}取消发布{% endif %}</a>
                            {# <div class="dropdown">
                            <div class="dropdown-toggle" data-toggle="dropdown">
                                <span class="fa fa-ellipsis-h" id="layer_show_{{ article.id }}"></span>
                            </div>
                            <ul class="dropdown-menu my-dropmenu" role="menu">
                                <li><a tabname="编辑文章 | {{article.title}}" class="J_menuItem" href="/admin/article/edit?articleId={{article.id}}">编辑</a></li>
                                <li>
                                    <input type="text" class="copy_target_input" id="copy_target_{{ article.id }}"  value="/admin/article/edit?articleId={{article.id}}"/>
                                    <a href="javascript:void(0)" class="clipUrl" articleId="{{ article.id }}" data-clipboard-action="copy" data-clipboard-target="#copy_target_{{ article.id }}" id="clip_borad_{{ article.id }}" >复制链接</a>
                                </li>
                                <li><a href="javascript:void(0)">预览(这个跳往前台)</a></li>
                                <li><a href="javascript:void(0)" class="delete_article" articleId="{{ article.id }}">删除</a></li>
                                <li><a href="javascript:void(0)" class="publish_article" articleId="{{ article.id }}" publish="{{ article.publish }}">{% if article.publish == 0%}发布{% else %}取消发布{% endif %}</a></li>
                            </ul> #}
                        </td>
                    </tr>
                    {% else %}
                    <tr>
                        <td colspan="10">
                            <!--没有数据时的显示-->
                            <div class="no-data-container">
                            <i class="fa fa-frown-o"></i>
                            <span>还没有文章哦~</span>
                            </div>
                            <!--/没有数据时的显示-->
                        </td>
                    </tr>
                    {% endfor %}
              </tbody>
            </table>
            <!--分页-->
            {% include '../component/page.html' %}
            <!--/分页-->
          </div>
          <!--/表格-->
        </div>
    </div>
    <!--/主体部分-->
</div>

{% endblock %} 
{% block script %}
<script src="/public/admin/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
<script src="/public/admin/js/plugins/clipborad/clipborad.js"></script>
<script src="/public/admin/js/common/article/list.js"></script>
<script src="/public/admin/js/common/util/pageBean.js"></script>
{% endblock %} 
